import java.util.ArrayList;

//1 to 1000, 1 number missed how you find?
public class Q5 {

	ArrayList<Object> findMiss(int[] numbers) {
		ArrayList<Object> missNumbers = new ArrayList<Object>();
	/*	for (int i = 0; i < numbers.length - 1; i++) {
			if ((numbers[i + 1] - numbers[i]) == 2) {
				missNumbers.add(numbers[i] + 1);
			}
			if ((numbers[i + 1] - numbers[i]) == 3) {
				missNumbers.add(numbers[i] + 1);
				missNumbers.add(numbers[i] + 2);
			}
			if ((numbers[i + 1] - numbers[i]) == 4) {
				missNumbers.add(numbers[i] + 1);
				missNumbers.add(numbers[i] + 2);
				missNumbers.add(numbers[i] + 3);
			}
		}*/
		for (int i = 0; i < numbers.length - 1; i++) {
			if ((numbers[i + 1] - numbers[i]) > 1) {
				int len = numbers[i + 1] - numbers[i];
				while (len > 1) {
					missNumbers.add(numbers[i + 1] - len + 1);
					len--;
				}
			}
		}
		return missNumbers;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		int[] numbers = { 1, 3, 4, 5, 6, 7, 9, 10, 12, 15, 16, 20 };
		Q5 q5 = new Q5();

		System.out.println("missing number is: "
				+ q5.findMiss(numbers).toString());
	}

}
